package com.eden.manage.controller;

import com.eden.manage.dto.PageComDto;
import com.eden.manage.dto.agent.AgentInviteDto;
import com.eden.manage.dto.agent.AgentProfitDto;
import com.eden.manage.req.query.AgentInviteQuery;
import com.eden.manage.req.query.AgentProfitQuery;
import com.eden.manage.service.AgentInviteService;
import eden.api.common.model.EdenPageResult;
import eden.api.common.model.EdenResult;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RequestMapping("agent/invite")
@RestController
@RequiredArgsConstructor
public class AgentInviteController {

    private final AgentInviteService agentInviteService;

    @PostMapping("index")
    public EdenPageResult<?> pageList(@RequestBody AgentInviteQuery query){
        PageComDto<AgentInviteDto> pageDto = agentInviteService.pageList(query);
        return EdenPageResult.ok(pageDto.getList(), pageDto.getCount());
    }

    @PostMapping("edit")
    public EdenResult<?> editPlat(@RequestBody AgentInviteDto agentInviteDto){
        agentInviteService.saveInvite(agentInviteDto);
        return EdenResult.ok("");
    }

    @PostMapping("cancel")
    public EdenResult<?> cancel(@RequestParam Long id){
        agentInviteService.cancelCode(id);
        return EdenResult.ok("");
    }
}
